﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Calculator.ViewModels;

namespace Calculator.Views
{
    /// <summary>
    /// Interaction logic for Calculator.xaml
    /// </summary>
    public partial class Calculator : UserControl
    {
        public Calculator()
        {
            InitializeComponent();
        }

        private void ButtonSum_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, '+');
            Result.Text = result.ToString();
        }

        private void ButtonSubtract_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, '-');
            Result.Text = result.ToString();
        }

        private void ButtonMultiply_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, '*');
            Result.Text = result.ToString();
        }

        private void ButtonDivide_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, '/');
            Result.Text = result.ToString();
        }

        private void ButtonSqrt_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, 'S');
            Result.Text = result.ToString();
        }

        private void ButtonPower_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, 'P');
            Result.Text = result.ToString();
        }

        private void ButtonLogarithm_Click(object sender, RoutedEventArgs e)
        {
            double result = (this.DataContext as ViewModelCalculator).CalculateResult(FirstNumber.Text, SecondNumber.Text, 'L');
            Result.Text = result.ToString();
        }
    }
}
